package com.tanhua.server.controller;

import com.tanhua.server.interceptors.UserHolder;
import com.tanhua.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;


    @PostMapping(value = "/location",name = "上报地理位置")
    public ResponseEntity saveLocation(@RequestBody Map map){
        Double  longitude = (Double) map.get("longitude");
        Double  latitude = (Double) map.get("latitude");
        String  addrStr = (String) map.get("addrStr");
        System.out.println(UserHolder.getUserId()+":"+map);
        return baiduService.saveLocation(longitude,latitude,addrStr);

    }
}
